package com.adcc.loadsheet.monitor.vo;

import com.adcc.loadsheet.monitor.entity.MonitorStatus;
import com.adcc.loadsheet.monitor.entity.MsgUpCenterMonitor;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.base.Strings;

import java.util.concurrent.ArrayBlockingQueue;

public class MsgUpCenterMonitorVO extends BaseVO<MsgUpCenterMonitor> {

    // 远程时间（运行程序的本地时间）
    private String remoteDateTime;

    // 本地时间（本地进行NTP授时，即NTP时间）
    private String localDateTime;

    // 时间分钟差
    private String minutesBetween;

    // NTP状态
    private boolean ntpStatus;

    // 上行状态（ACARS接收）
    private boolean uplinkStatus;

    // 下行状态（ACARS发送）
    private boolean downlinkStatus;

    // 报文总数
    private long totalCount;

    // 舱单报文数
    private long loadsheetCount;

    // 名单报文数
    private long passgerlistCount;

    // 错误报文数
    private long failCount;

    // 监控状态
    private MonitorStatus status;

    // 舱单统计数据队列
    private ArrayBlockingQueue<Long> loadsheetData;

    // 名单统计数据队列
    private ArrayBlockingQueue<Long> passgerlistData;

    // 最后一次统计数据更新时间
    private long updateTime;

    // 时间跨度（折线图X轴时间刻度）
    private int timespan;

    // 数据个数（折线图数据点）
    private int points;

    public MsgUpCenterMonitorVO() {

    }

    public MsgUpCenterMonitorVO(MsgUpCenterMonitor msgUpCenterMonitor) {
        remoteDateTime = Strings.nullToEmpty(msgUpCenterMonitor.getRemoteDateTime());
        localDateTime = Strings.nullToEmpty(msgUpCenterMonitor.getLocalDateTime());
        if(msgUpCenterMonitor.getMinutesBetween() >= 0) {
            minutesBetween = "+" + Math.abs(msgUpCenterMonitor.getMinutesBetween());
        } else {
            minutesBetween = "-" + Math.abs(msgUpCenterMonitor.getMinutesBetween());
        }
        ntpStatus = msgUpCenterMonitor.isNtpStatus();
        uplinkStatus = msgUpCenterMonitor.isUplinkStatus();
        downlinkStatus = msgUpCenterMonitor.isDownlinkStatus();
        totalCount = msgUpCenterMonitor.getTotalCount();
        loadsheetCount = msgUpCenterMonitor.getLoadsheetCount();
        passgerlistCount = msgUpCenterMonitor.getPassgerlistCount();
        failCount = msgUpCenterMonitor.getFailCount();
        status = msgUpCenterMonitor.getStatus();
        loadsheetData = msgUpCenterMonitor.getLoadsheetData();
        passgerlistData = msgUpCenterMonitor.getPassgerlistData();
        updateTime = msgUpCenterMonitor.getUpdateTime();
        timespan = msgUpCenterMonitor.getTimespan();
        points = msgUpCenterMonitor.getPoints();
    }

    public String getRemoteDateTime() {
        return remoteDateTime;
    }

    public void setRemoteDateTime(String remoteDateTime) {
        this.remoteDateTime = remoteDateTime;
    }

    public String getLocalDateTime() {
        return localDateTime;
    }

    public void setLocalDateTime(String localDateTime) {
        this.localDateTime = localDateTime;
    }

    public String getMinutesBetween() {
        return minutesBetween;
    }

    public void setMinutesBetween(String minutesBetween) {
        this.minutesBetween = minutesBetween;
    }

    public boolean isNtpStatus() {
        return ntpStatus;
    }

    public void setNtpStatus(boolean ntpStatus) {
        this.ntpStatus = ntpStatus;
    }

    public boolean isUplinkStatus() {
        return uplinkStatus;
    }

    public void setUplinkStatus(boolean uplinkStatus) {
        this.uplinkStatus = uplinkStatus;
    }

    public boolean isDownlinkStatus() {
        return downlinkStatus;
    }

    public void setDownlinkStatus(boolean downlinkStatus) {
        this.downlinkStatus = downlinkStatus;
    }

    public long getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(long totalCount) {
        this.totalCount = totalCount;
    }

    public long getLoadsheetCount() {
        return loadsheetCount;
    }

    public void setLoadsheetCount(long loadsheetCount) {
        this.loadsheetCount = loadsheetCount;
    }

    public long getPassgerlistCount() {
        return passgerlistCount;
    }

    public void setPassgerlistCount(long passgerlistCount) {
        this.passgerlistCount = passgerlistCount;
    }

    public long getFailCount() {
        return failCount;
    }

    public void setFailCount(long failCount) {
        this.failCount = failCount;
    }

    public MonitorStatus getStatus() {
        return status;
    }

    public void setStatus(MonitorStatus status) {
        this.status = status;
    }

    public ArrayBlockingQueue<Long> getLoadsheetData() {
        return loadsheetData;
    }

    public void setLoadsheetData(ArrayBlockingQueue<Long> loadsheetData) {
        this.loadsheetData = loadsheetData;
    }

    public ArrayBlockingQueue<Long> getPassgerlistData() {
        return passgerlistData;
    }

    public void setPassgerlistData(ArrayBlockingQueue<Long> passgerlistData) {
        this.passgerlistData = passgerlistData;
    }

    public long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(long updateTime) {
        this.updateTime = updateTime;
    }

    public int getTimespan() {
        return timespan;
    }

    public void setTimespan(int timespan) {
        this.timespan = timespan;
    }

    public int getPoints() {
        return points;
    }

    public void setPoints(int points) {
        this.points = points;
    }

    @Override
    public MsgUpCenterMonitor toEntity() {
        return null;
    }

    @Override
    public String toJSON() throws JsonProcessingException {
        return null;
    }
}
